package entities;

import java.awt.Graphics2D;
import main.Simulation;

/**
 * Creates a Temporarily existing spring.
 * @author Paul
 * @author Lance
 */
public class TemporarySpring extends Spring {

    /**
     * Builds a TemporarySpring
     * @param pointObject
     * @param pointObject2
     * @param length
     * @param kVal
     */
    public TemporarySpring(PointObject pointObject, PointObject pointObject2,
            double length, double kVal) {
        super(pointObject, pointObject2, length, kVal);
    }

    @Override
    public void update(Simulation canvas, double dt) {
        if (isConnected()) {
            super.update(canvas, dt);
        }
    }  
    
    /**
     * Paints object only if it is still connected
     * to temporary masses.
     */
    @Override
    public void paint(Graphics2D pen) {
        if (isConnected()) {
            super.paint(pen);
        }
    }
    
    
    private boolean isConnected() {
        return (getStart() != null && getEnd() != null);
    }
}
